package com.tony.akka;

import akka.actor.AbstractActor;
import akka.actor.Props;
import akka.event.Logging;
import akka.event.LoggingAdapter;

/**
 * @version V1.0  </br>
 * @ClassName Printer </br>
 * @Description TODO  </br>
 * @Author tonywang</br>
 * @DATE 3/18/2019 10:42 AM</br>
 */
public class Printer extends AbstractActor {

    public static Props props() {
        return Props.create(Printer.class,() -> new Printer());
    }

    //#printer-messages

    private LoggingAdapter log = Logging.getLogger(getContext().getSystem(), this);

    public Printer() {
    }

    static public class Greeting {
        public final String message;

        public Greeting(String message) {
            this.message = message;
        }
    }

    @Override
    public Receive createReceive() {
        return receiveBuilder().match(Greeting.class, pGreeting -> {
            log.info(pGreeting.message);
        }).build();
    }
}
